package com.qqtech.qquan.send.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import com.qqtech.core.common.util.BeanUtil;
import com.qqtech.core.frame.dao.BaseDaoImpl;
import com.qqtech.qquan.send.model.SendDeliveryUser;
import com.qqtech.qquan.send.model.SendDeliveryUserVo;

@Repository
public class SendDeliveryUserDaoImpl extends BaseDaoImpl<SendDeliveryUser> implements SendDeliveryUserDao {
	public static final Logger log = LoggerFactory.getLogger(SendDeliveryUserDaoImpl.class);
	
	public SendDeliveryUser getByUserId(java.lang.Integer userId) {
		return sqlSessionTemplate.selectOne(getSqlName("selectByUserId"), userId);
	}

	@Override
	public int queryCountByAdmin(SendDeliveryUser query) {
		return sqlSessionTemplate.selectOne(getSqlName("selectCountByAdmin"), BeanUtil.toMap(query));
	}

	@Override
	public Page<SendDeliveryUserVo> queryPageListByAdmin(
			SendDeliveryUser query, Pageable pageable) {
		List<SendDeliveryUserVo> contentList = sqlSessionTemplate.selectList(getSqlName("selectByAdmin"), getParams(query, pageable));
		return new PageImpl<SendDeliveryUserVo>(contentList, pageable, this.queryCountByAdmin(query));
	}	
}
